Page({
  data: {
    //获取从哪个徽章点击进来
    hid: null,
    //接收当前选中的徽章
    selLv: null,
    //服务协议开关
    showxy: false,

    //获得当前徽章总人数
    sumrs: 436456,
    //VIP到期时间
    viptime: 365,
    //优惠券金额
    youhui: 5,
    //用户徽章等级参数
    lvdata: { "lv": "2","progress":21}
  },
  //获取从什么标记进入的页面
  onLoad: function (options) {
    var _this = this
    _this.setData({
      hid: options.h_id
    })
    if (_this.data.hid == 1) {
      wx.setNavigationBarTitle({
        title: '圈主晋级徽章'
      })
    }
    if (_this.data.hid == 2) {
      wx.setNavigationBarTitle({
        title: '学习成长徽章'
      })
    }
    if (_this.data.hid == 3) {
      wx.setNavigationBarTitle({
        title: '兴趣分享徽章'
      })
    }
    if (_this.data.hid == 4) {
      wx.setNavigationBarTitle({
        title: '橙贝兑换徽章'
      })
    }
    if (_this.data.hid == 5) {
      wx.setNavigationBarTitle({
        title: '兴趣专辑徽章'
      })
    }
    if (_this.data.hid == 6) {
      wx.setNavigationBarTitle({
        title: '特别贡献徽章'
      })
    }
    var lvd = _this.data.lvdata.lv
    if (lvd!=0){
      _this.setData({
      selLv: lvd
    })
    }else{
      _this.setData({
        selLv: 1
      })
    }
    console.log(_this.data.selLv)
  },
  onShareAppMessage() {
    return {
      title: '好玩的百科知识平台',
      desc: '',
      path: '/pages/home/home'
    }
  },
  //切换卡片
  selectbadge: function (e) {
    var _this = this
    var sel = e.detail.current;
    var sum = parseInt(_this.data.sumrs / 6) 
    _this.setData({
      selLv: parseInt(sel) + 1,
      sumrs: sum
    })
  },
  //打开协议页面
  openxy: function(){
    var _this = this
    _this.setData({
      showxy: true
    })
  },
  //关闭协议
  closexy: function(){
    var _this = this
    _this.setData({
      showxy: false
    })
  },
  //跳转优惠券包
  gotowallet: function () {
    wx.navigateTo({
      url: '../wallet/wallet',
    })
  },
})